Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the formatting of octal integers. #18

Closed
wants to merge 1 commit into from
Closed

Fix the formatting of octal integers. #18

wants to merge 1 commit into from

Conversation

abachrach
Copy link

{0:#o}.format(42)

was being formatted as: "052"
instead of "0o52"

{0:#o}.format(42)

as being formatted as: "052"
instead of "0o52"
@vitaut
Copy link
Contributor

vitaut commented Feb 10, 2014

Thanks for the patch, but the library follows C/C++ convention for representing octal numbers as documented here:

For integers, when binary, octal, or hexadecimal output is used, this option adds the prefix respective "0b" ("0B"), "0", or "0x" ("0X") to the output value.

It is possible to specify "0o" prefix explicitly of course, e.g. "0o{:o}".

@vitaut vitaut closed this Feb 10, 2014
@abachrach
Copy link
Author

Makes sense.

In the end it's kind of arbitrary, but I would have thought it would match
the python .format semantics (which is more logical IMO).

On Mon, Feb 10, 2014 at 1:37 PM, vitaut [email protected] wrote:

Thanks for the patch, but the library follows C/C++ convention for
representing octal numbers as documented herehttp://zverovich.net/format/
:

For integers, when binary, octal, or hexadecimal output is used, this
option adds the prefix respective "0b" ("0B"), "0", or "0x" ("0X") to the
output value.

It is possible to specify "0o" prefix explicitly of course, e.g. "0o{:o}".

Reply to this email directly or view it on GitHubhttps://github.com//pull/18#issuecomment-34685552
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants